home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / LISTINGS / V_12_11 / ALLISON / EXHAUST3.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-04  |  450 b   |  27 lines

  1. LISTING 19 - Leaves a bad_alloc exception uncaught to force
  2. terminate()
  3. // exhaust3.cpp
  4. #include <iostream.h>
  5.  
  6. main()
  7. {
  8.     for (int i = 0; ; ++i)
  9.     {
  10.         (void) new double[100];
  11.         if ((i+1)%10 == 0)
  12.             cout << (i+1) << " allocations" << endl;
  13.     }
  14. }
  15.  
  16. /* Output:
  17. 10 allocations
  18. 20 allocations
  19. 30 allocations
  20. 40 allocations
  21. 50 allocations
  22. 60 allocations
  23. 70 allocations
  24. Abnormal program termination
  25. */
  26.  
  27.